import store from '../store'
import axios from 'axios'
const http = axios.create({
  baseURL: 'http://geek.itheima.net/v1_0',
  timeout: 5000,
})
export { http }
// 请求拦截器
http.interceptors.request.use((config) => {
  const { login: token } = store.getState()
  if (!config.url.startsWith('/authorizations')) {
    config.headers.Authorization = `Bearer ${token}`
  }
  return config
})
// 响应拦截器
http.interceptors.response.use(undefined, (error) => {
  return Promise.reject(error)
})
